﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace DepSoft.UI.WPF.iWatchSyncer
{
    public static class GenericExtensions
    {
        public static bool ContainsFolder(this List<string> folders, string folder)
        {
            while (!string.IsNullOrEmpty(folder) && !Path.GetPathRoot(folder).Equals(folder, StringComparison.OrdinalIgnoreCase) && !folders.Contains(folder))
            {
                return folders.ContainsFolder(Directory.GetParent(folder).FullName);
            }

            return folders.Contains(folder);
        }
    }
}
